<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<jsp:include page="/WEB-INF/jsp/iframe/base_title.jsp"/>
<link href="css/styles.css" rel="stylesheet" type="text/css" />
<link href="css/nav_style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<style type="text/css">
.menu_left {
	height: 26px;
	padding-left: 8px;
	width: 100%;
}

ol,ul,li {
	list-style: none outside none;
}

#main_index {
	width: 1002px;
	margin: auto;
}

#main_index_top {
	background: url("") repeat-x scroll left top transparent;
	height: 40px;
	left: 0;
	padding-bottom: 0;
	position: fixed;
	right: 0;
	top: 0;
	z-index: 1023;
	text-align: center;
}

.mod-topbar {
	background: none repeat scroll 0 0 transparent;
	width: 1002px;
	margin: auto;
}
</style>
</head>
<body>
	<div id="main_index">
		<div id="main_index_top">
			<div class="mod-topbar" style="text-align: center;">dsdfsdfsdfdsfdsf
				hhh</div>
		</div>
		<jsp:include page="/WEB-INF/jsp/iframe/main_nav.jsp"></jsp:include>
	</div>
	<form action="<s:url action="showImg" namespace=""/>" method="post">
	<textarea id="B64Code" name="B64Code" cols="64" rows="20"></textarea>
	<img id="apDiv1" alt="签章" src="" style="position:absolute;left:0px;top:0px;"/>
	
	</form><button name="test"  onclick="getSeal()" >获取B64编码</button>
			<button name="test1"  onclick="getPicCode()" >显示签章</button>
			<input type="button" value="签章" onclick="qianzhang()">
	<script type="text/javascript">
	$(document).ready(function(){
		var obj = $('<object classid="clsid:C02DECFC-D82E-4F22-A8A9-9476AA1A7EB0" id="gseal" name="gseal" id="gseal" width="0" height="0" ></object>');
		$("body").append(obj);
	});
		
		function err(response, textStatus, errorThrown) {
			alert("响应失败：" + response.status);
		}

		/**
		 * 传入承载对象的ID
		 **/
		function qianzhang(parentId) {
			if (!$.browser.msie) {
				alert("仅支持IE6及以上浏览器！");
				return;
			}
			// 			创建一个承载对象imgSeal
			if ($("#imgSeal").length <= 0) {
				var html = $('<img id="imgSeal" alt="" width="130" height="130" src="" style="position: absolute; top: 200px; left: 210px; cursor:pointer;display: none ">');
				if (parentId) {
					$("#" + parentId).append(html);
				} else {
					$("body").append(html);
				}
			}
			$("#B64Code").val($("body").html());

			$("#imgSeal").attr("src", "");
			$("#imgSeal").css("display", "none");//隐藏
			$("#imgSeal").unbind();//取消所有绑定事件

			var seal = gseal.JSCAGetSeal();
			if (seal == null || seal == "") {
				return;
			}
			var formData = "&B64Code=" + encodeURIComponent(seal);
			$("body").css("cursor", "wait");
			$.ajax({
				type : "post",
				url : "<s:url action="showImg" namespace=""/>",
				data : formData,
				async : false,
				dataType : "text",
				success : function(result) {
					$("body").css("cursor", "auto");
					$("#imgSeal").attr("src", result);
					$("#imgSeal").css("display", "");
					$("#imgSeal").bind('mousedown', down);
					$("#imgSeal").bind('mouseup', up);
					$("#imgSeal").bind('mousemove', move);

				},
				error : function(response, textStatus, errorThrown) {
					$("body").css("cursor", "auto");
					err(response, textStatus, errorThrown);
				}
			});
		}
	</script>
	
	<script type="text/javascript">
		//Pre-load your images here.
		var ie = (document.all);
		
		var y = null;
		var x = null;
		var z = null;
		var w = null;
		
		function down() {
			if (ie) {
				z = window.event.srcElement;
				z.style.cursor = "move";
				y = window.event.offsetY;
				x = window.event.offsetX;
				//w = window.event.srcElement.parentElement.id.charAt(window.event.srcElement.parentElement.id.length - 1);
				//window.event.srcElement.style.zIndex = n++;
			}
			return false;
		}
		function move() {
			if (ie && z) {
				z.style.posLeft = window.event.clientX - x;
				z.style.posTop = window.event.clientY - y;
			}
			return false;
		}
		function up() {
			if (ie)
				z.style.cursor = "pointer";
				document.onmousemove = null;
			z = null;
		}
		
// 		function qianzhang(){
// 			$("#imgSeal").attr("src","images/zhang.png");
// 		} 
	//-->
	</script>
</body>
</html>